package com.dg.gaming.server.data.mysql;

import java.sql.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class PrepareStatmentObject {
    private String sql;
    private ThreadLocal<PreparedStatement> prepareStmt = new ThreadLocal<PreparedStatement>();

    public PrepareStatmentObject(String sql) {
        this.sql = sql;
    }

    public PreparedStatement prepare(Connection con) throws Exception {
        PreparedStatement ps = prepareStmt.get();
        if (ps == null) {
            ps = con.prepareStatement(getSql());
            prepareStmt.set(ps);
        }
        return ps;
    }


    public String getSql() {
        return sql;
    }

    public PreparedStatement getPrepareStmt() {
        return prepareStmt.get();
    }


}
